<template>
    <view class="bg-content">

        <div style="background-color: white; margin-bottom: 10px;" v-for="(item, index)  in tbDistributorList" :key="index">
            <u-cell-item :arrow="false" use-label-slot :title-style="{'width': '100%'}"
                         @click="navigateTo(`/pages/sub/sub2-store-platform/store-platform/store-platform-distributor/store-platform-distributor-detail/index`, {prevStoreId: item.nextStoreId})">
                <div slot="icon">
                    <myImg :obj="item.nextTbStore" :key="item.id"
                           :sysFile="{fkId: item.nextTbStore.userId, typeMark: 'user-avatar'}"
                           :customStyle="'pointer-events: none; height: 100px;  width:100px; background-size: cover; background-repeat: no-repeat; background-position: center;'"
                           :defaultUrl="'/pages/sub/sub2-store-platform/static/default-image/user-avatar.png'"
                           :imageView="'imageView2/1/w/150/h/150'"
                    ></myImg>
                </div>
                <div slot="title" style="padding-left: 10px;">
                    {{item.nextTbStore.sysUser.name}}
                </div>
                <div slot="label">
                    <span class="skin-font">产生收益：￥{{item.earnings | toFixed2}}</span>
                    <span style="margin-left: 10px;">粉丝数：{{item.nextTbDistributorCount}}</span>
                </div>
                <div slot="right-icon">
                </div>
                <!--默认value属性-->
                <div>
                </div>
            </u-cell-item>
        </div>

        <div style="padding-top: 10px; padding-bottom: 10px;">
            <u-loadmore :status="pagination.status" bg-color="#eeeeee"/>
        </div>
    </view>
</template>

<script>

    import myImg from '@/components/my-img'
    import {TbDistributorService} from "@/dev/services/tb-distributor.service";

    export default {
        data() {
            return {
                tbDistributorList: [],
            }
        },
        components: {
            myImg
        },
        onShow() {
            const _self = this;
            _self.doRefresh(this.tbDistributorList);
        },
        // 上拉加载
        onReachBottom: function () {
            if (this.pagination.hasNextPage) {
                this.doInfinite()
            }
        },
        methods: {
            /**
             * 加载更多数据中
             * @param infiniteScroll
             */
            doInfinite(infiniteScroll) {
                const _self = this;
                new TbDistributorService().findTableListCascade({
                    pagination: _self.pagination,
                    data: {
                        prevStoreId: _self.globalVariable.userInfo.tbStore.id,
                        isContainThirdEarnings: true,
                        orderBy: 'create_time desc'
                    },
                }).then(result => {
                    _self.pagination.refreshPage(result);
                    _self.tbDistributorList = [..._self.tbDistributorList, ...result.list];
                });
            },
        }
    }
</script>

<style lang="scss" scoped>
</style>
